/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.DealFieldManager;
/*    */ import com.newcrm.db.DealManager;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.sql.SQLException;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import javax.servlet.RequestDispatcher;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class ShowDeal extends AbstractAction
/*    */ {
/* 24 */   private int id = 0;
/* 25 */   private boolean isH5 = false;
/*    */ 
/* 27 */   private static Logger logger = Logger.getLogger(ShowDeal.class.getName());
/*    */ 
/*    */   public ShowDeal(AbstractHttpServlet servlet) {
/* 30 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public ShowDeal(AbstractHttpServlet servlet, String id) {
/* 34 */     super(servlet);
/* 35 */     this.id = Util.str2Int(id);
/*    */   }
/*    */ 
/*    */   public ShowDeal(AbstractHttpServlet servlet, String id, boolean isH5) {
/* 39 */     super(servlet);
/* 40 */     this.id = Util.str2Int(id);
/* 41 */     this.isH5 = isH5;
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 47 */     User user = super.getLoginUser(request);
/* 48 */     DealManager manager = new DealManager();
/* 49 */     Map dealInfo = manager.getDealInfo(this.id);
/* 50 */     if ((dealInfo == null) || (dealInfo.size() == 0)) {
/* 51 */       throw new NotFoundException();
/*    */     }
/*    */ 
/* 55 */     List extInfos = manager.getDealExtInfo(this.id);
/* 56 */     request.setAttribute("extInfos", extInfos);
/*    */ 
/* 59 */     String responsibleUserId = (String)dealInfo.get("ResponsibleUserId");
/*    */ 
/* 63 */     if (!user.hasViewDealRight(responsibleUserId, 
/* 63 */       super.getCompany(user.companyId))) {
/* 64 */       throw new NotFoundException();
/*    */     }
/*    */ 
/* 67 */     List customerInfo = null;
/*    */     try {
/* 69 */       customerInfo = manager.getDealCustomerInfo(this.id);
/*    */     } catch (SQLException e) {
/* 71 */       logger.warn("get deal customer failed", e);
/*    */     }
/*    */ 
/* 74 */     DealFieldManager manager2 = new DealFieldManager();
/*    */     try {
/* 76 */       List fields = manager2.list(user.companyId);
/* 77 */       request.setAttribute("fields", fields);
/*    */     } catch (Exception e) {
/* 79 */       logger.warn("get company customer field info failed", e);
/*    */     }
/*    */ 
/* 82 */     request.setAttribute("dealInfo", dealInfo);
/* 83 */     request.setAttribute("customerInfo", customerInfo);
/*    */ 
/* 85 */     if (this.isH5) {
/* 86 */       request.getRequestDispatcher("/mobileV2/dealDetail.jsp").forward(
/* 87 */         request, response);
/* 88 */       return;
/*    */     }
/* 90 */     request.getRequestDispatcher("/deal_detail.jsp").forward(request, 
/* 91 */       response);
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.ShowDeal
 * JD-Core Version:    0.6.1
 */